- expanded = expanded_by_default?
- can_admin_project = can?(current_user, :admin_project, @project)

- if @project.licensed_feature_available?(:protected_environments)
  %section.protected-environments-settings.settings.no-animate#js-protected-environments-settings{ class: ('expanded' if expanded) }
    .settings-header
      %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
        = _('Protected environments')
      = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle' }) do
        = expanded ? _('Collapse') : _('Expand')
      %p
        = s_('ProtectedEnvironment|Only specified users can execute deployments in a protected environment.')
    .settings-content
      - if @protected_environments.empty?
        = render Pajamas::AlertComponent.new(variant: :warning, show_icon: false, dismissible: false,
          alert_options: { class: 'gl-mb-5'}) do |c|
          - c.with_body do
            = s_('ProtectedEnvironment|No environments in this project are protected.')

      = render 'projects/protected_environments/form'

      = render partial: 'projects/protected_environments/environments_list', locals: { can_admin_project: can_admin_project }
      = render partial: 'projects/protected_environments/group_environments_list'
      = render 'projects/protected_environments/deployment_approval_options', project: @project
